package com.flow.dao.impl;

import java.util.ArrayList;
import java.util.List;
import com.flow.dao.IRolePermissionDao;
import com.flow.model.PagerModel;
import com.flow.model.RolePermission;

/**
 * 角色权限Dao实现类
 * @author Wang
 * @param <T>
 */
public class RolePermissionDao<T> extends BaseDao<T> implements IRolePermissionDao<T>{

	@Override
	public boolean insertRolePermission(RolePermission rolePermission) {

		try {

			insert(rolePermission);
			return true;

		} catch (Exception e) {

			e.printStackTrace();

		}

		return false;
	}

	@Override
	public boolean updateRolePermission(RolePermission rolePermission) {
		
		try {

			update(rolePermission);
			return true;

		} catch (Exception e) {

			e.printStackTrace();

		}
		
		return false;
	}

	@Override
	public boolean deleteRolePermission(RolePermission rolePermission) {
		
		try {

			delete(rolePermission);
			return true;

		} catch (Exception e) {

			e.printStackTrace();

		}
		
		return false;
	}

	@Override
	public RolePermission findRolePermissionByHql(String hql) {

		return findRolePermissionByHql(hql, null);
		
	}

	@Override
	public RolePermission findRolePermissionByHql(String hql, Object param) {

		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return findRolePermissionByHql(hql, params);
		
	}

	@Override
	public RolePermission findRolePermissionByHql(String hql, List<Object> params) {
		
		return (RolePermission) findByHql(hql, params);
		
	}

	@Override
	public int universalMethodRolePermission(String hql) {

		return universalMethodRolePermission(hql, null);
		
	}

	@Override
	public int universalMethodRolePermission(String hql, Object param) {

		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return universalMethodRolePermission(hql, params);
		
	}

	@Override
	public int universalMethodRolePermission(String hql, List<Object> params) {

		return universalMethod(hql, params);
		
	}

	@Override
	public List<T> findRolePermissionAllByHql(String hql) {

		return findRolePermissionAllByHql(hql, null);
		
	}

	@Override
	public List<T> findRolePermissionAllByHql(String hql, Object param) {

		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return findRolePermissionAllByHql(hql, params);
		
	}

	@Override
	public List<T> findRolePermissionAllByHql(String hql, List<Object> params) {

		return findAllByHql(hql, params);
	}

	@Override
	public PagerModel findRolePermissionPagerModeled(PagerModel pager, String hql) {
		
		return findRolePermissionPagerModeled(pager, hql, null);
		
	}

	@Override
	public PagerModel findRolePermissionPagerModeled(PagerModel pager, String hql, Object param) {
		
		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return findRolePermissionPagerModeled(pager, hql, params);
		
	}

	@Override
	public PagerModel findRolePermissionPagerModeled(PagerModel pager, String hql, List<Object> params) {

		return findPagerModeled(pager, hql, params);
		
	}

}
